<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>FlashBee-Short-Url 短链接</title>
    <link rel="stylesheet" href="/layui/css/layui.css">
    <link rel="stylesheet" href="/layui/css/login.css">
    <script src="/layui/js/jquery-3.7.1.min.js"></script>
    <script src="/layui/js/sweetalert.min.js"></script>
    <link rel="icon" href="/images/favicon.ico">
</head>
<body>
<div id="content">
    <h2>FlashBee-Short-Url 短链接</h2>
    <div class="layui-form-item">
        <label class="layui-form-label">密码:</label>
        <div class="layui-input-inline">
            <input type="password" name="password" required lay-verify="required" placeholder="请输入密码"
                   autocomplete="off" class="layui-input" id="password">
        </div>
        <button type="button" class="layui-btn layui-btn-normal layui-btn-sm" id="login">
            <i class="layui-icon layui-icon-ok "></i>
        </button>
    </div>
</div>
<script>
    $("#login").click(function () {
        let password = $("#password").val()
        $.ajax({
            url: "/auth/login",
            type: "POST",
            dataType: "json",
            contentType: 'application/json',
            data: JSON.stringify({password: password}),
            success: function (res) {
                if (res.code === 200) {
                    location.href = "/"
                } else {
                    swal("","你输入的密码错误！", "error")
                }
            }
        })
    })
</script>
<script src="/layui/layui.js"></script>
</body>
</html>